/**
 * @Title: MaterialType.java 
 * @Description: TODO
 * @author <a href="mailto:psammead@126.com">Psammead</a>
 * @date 2011-7-16 上午10:32:28 
 * @version 1.0
 * Copyright 2011 by Psammead
 */
package com.psammead.dms.offer.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.psammead.dms.common.core.bo.AbstractBaseBO;

/**
 * @ClassName: MaterialType
 * @Description: TODO
 * @author <a href="mailto:psammead@126.com">psammead</a>
 * @version 1.0
 * @date 2011-7-16
 */
@Entity(name="MaterialType")
@Table(name="tb_of_material_type")
public class MaterialType extends AbstractBaseBO implements Serializable{


	/**
	 * @Fields serialVersionUID : TODO
	 */
	private static final long serialVersionUID = -1666855026478238510L;
	private long id;
	private String name;
	private int sort;
	
	private Set<OfferTemplate> templates=new HashSet<OfferTemplate>();
	private Set<Offer> offers=new HashSet<Offer>();
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name="type_id")
	@Override
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}
	
	@Column(name="type_name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name="sort")
	public int getSort() {
		return sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}
	
	@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE},mappedBy="types", fetch = FetchType.LAZY)
	public Set<OfferTemplate> getTemplates() {
		return templates;
	}

	public void setTemplates(Set<OfferTemplate> templates) {
		this.templates = templates;
	}

	@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE},mappedBy="types", fetch = FetchType.LAZY)
	public Set<Offer> getOffers() {
		return offers;
	}

	public void setOffers(Set<Offer> offers) {
		this.offers = offers;
	}


}
